//
// Created by dave on 18-7-31.
//

#pragma once
#include <chrono>
#include <ctime>
//#include <cassandra.h>
#include "../codec/data_utils.h"
#include "../codec/data_pack.h"
#include "../codec/terminal/location_report.h"

using namespace std::chrono;

struct location {
public:
    location() = default;

    location(DataPack& report) {
        sim = report.getSim();
        auto r = std::dynamic_pointer_cast<LocationReport>(report.getBody());
        time = r->getTime();
//        CassUuidGen* uuid_gen = cass_uuid_gen_new();
//        cass_uuid_gen_time(uuid_gen, &uuid);
//        cass_uuid_gen_free(uuid_gen);

        alarm = r->getAlarm();
        flag = r->getFlag();
        located = r->isLocated();
        lat = r->getLat();
        lng = r->getLng();
        height = r->getHeight();
        speed = r->getSpeed();
        direction = r->getDirection();
    }

    std::string getSim() const { return sim; }
    void setSim(std::string sim) { this->sim = sim; }

//    CassUuid getUuid() const { return this-> uuid; }
//    void setUuid(CassUuid uuid) { this->uuid = uuid; }

    time_t getTime() const { return time; }
    void setTime(time_t time) { this->time = time; }

    unsigned getAlarm() const { return alarm; }
    void setAlarm(unsigned alarm) { this->alarm = alarm; }

    unsigned getFlag() const { return flag; }
    void setFlag(unsigned flag) { this->flag = flag; }

    bool isLocated() const { return located; }
    void setLocated(bool located) { this->located = located; }

    double getLat() const { return lat; }
    void setLat(double lat) { this->lat = lat; }

    double getLng() const { return lng; }
    void setLng(double lng) { this->lng = lng; }

    int getHeight() const { return height; }
    void setHeight(int height) { this->height = height; }

    int getSpeed() const { return speed; }
    void setSpeed(int speed) { this->speed = speed; }

    int getDirection() const { return direction; }
    void setDirection(int direction) { this->direction = direction; }

private:
    std::string sim;
//    CassUuid uuid;
    time_t time;
    unsigned alarm;
    unsigned flag;
    bool located;
    double lat;
    double lng;
    int height;
    int speed;
    int direction;
};